<!DOCTYPE html>
<html>
  <head>
    <title>Markdown Editor</title>
    <script src="https://unpkg.com/vue@2"></script>
    <script src="https://unpkg.com/marked@0.3.6"></script>
    <script src="https://unpkg.com/lodash@4.16.0"></script>
    <link rel="stylesheet" type="text/css" href="/style.css" />
  </head>
  <body>
    <div id="editor">
      <textarea :value="input" @input="update"></textarea>
      <div v-html="compiledMarkdown"></div>
    </div>

    <script>
      new Vue({
        el: "#editor",
        data: {
          input: "# hello"
        },
        computed: {
          compiledMarkdown: function() {
            return marked(this.input, { sanitize: true });
          }
        },
        methods: {
          update: _.debounce(function(e) {
            this.input = e.target.value;
          }, 300)
        }
      });
    </script>
  </body>
</html>
